<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:p="http://primefaces.org/ui" template="/layout/template.xhtml">
	<ui:define name="body">
	<script language="JavaScript" type="text/javascript">
		window.history.forward(-1);
	</script>
		<h1 class="title ui-widget-header ui-corner-all">#{message['entrega.letras.tittle']}</h1>
		<h:form id="formEntregaLetras">
		<p:messages showDetail="true"/>
		<p:panel>
		<p:fieldset id="fi" legend="Consutar Contrato">
			
		<p:selectOneRadio  value="#{contratoForm.radio}" onchange="" >  
	        <f:selectItem itemLabel="Estado" itemValue="1"/>
	        <f:selectItem itemLabel="Por fechas" itemValue="2" />
	         <f:selectItem itemLabel="Nro de Documento" itemValue="3" />
	        <f:selectItem itemLabel="Nombres Completos" itemValue="4" />
	        <p:ajax update="fi" />
        </p:selectOneRadio>
        
        	<h:panelGrid columns="2" rendered="#{contratoForm.radio==1}" >
	        	<h:outputText value="#{message['entrega.estado']}" />
				<p:selectOneMenu  style="width:220px" value="#{contratoForm.idtipodoc}" required="true" >
					<f:selectItems value="#{comboAction.estadoitems}" />
				</p:selectOneMenu>
			</h:panelGrid>
			
			<h:panelGrid columns="3" rendered="#{contratoForm.radio==2}"  >
				<h:outputText value="Desde" />
				<p:calendar value="#{contratoForm.objClienteSie.fecnacimiento}" required="true" pattern="dd/MM/yyyy" size="10" locale="es"
					pagedate="01/01/1990" maxdate="today" />
				<h:outputText value="Hasta" />
				<p:calendar value="#{contratoForm.objClienteSie.fecnacimiento}" required="true" pattern="dd/MM/yyyy" size="10" locale="es"
					pagedate="01/01/1990" maxdate="today" />
			</h:panelGrid>
			
			<h:panelGrid columns="2" rendered="#{contratoForm.radio==3}" >
			
			<h:outputText value="#{message['contrato.tipo.documento']}" />
			<p:selectOneMenu id="tipoDoc" style="width:200px" value="#{entregaForm.idtipodoc}" required="true" 
				requiredMessage="#{message['contrato.tipo.documento.validation']}" >
				<f:selectItems value="#{comboAction.tipoDocumentoitems}" />
				<p:ajax update="nrodoc"/>
			</p:selectOneMenu>
			
			<h:outputText value="#{message['contrato.numero.documento']}" />
			<h:panelGroup id="nrodoc">
				<p:inputMask value="#{contratoForm.numDniCliente}" mask="99999999"
					rendered="#{contratoForm.idtipodoc==1}" required="true" />
					
				<p:inputMask value="#{contratoForm.numDniCliente}" mask="99999999999"
					rendered="#{contratoForm.idtipodoc==2}" required="true"/>
			</h:panelGroup>
			</h:panelGrid>
			
			<h:panelGrid columns="3" rendered="#{contratoForm.radio==4}" >
	        	<h:outputText value="Nombres: " />
				<p:inputText id="nom" value="#{entregaForm.nombreCliente}" />
				<h:outputText value="Apellido Paterno: " />
				<p:inputText id="app" value="#{entregaForm.apePatCliente}" />
				<h:outputText value="Apellido Materno: " />
				<p:inputText id="apm" value="#{entregaForm.apeMatCliente}" />
			</h:panelGrid>
			
			<p:commandButton value="Consultar" action="#{entregaForm.consultar}" update="message" ajax="false" icon="ui-icon-search"/>
					
				</p:fieldset>
				
				<h:panelGrid style="margin-top:30px" >
					<p:dataTable value="#{entregaForm.contratoList}" paginator="true" sortMode="multiple" rowsPerPageTemplate="5,10,15" 
					rows="5" var="c" style="width:800px" emptyMessage="#{message['rsltd.empty']}" >
						
						<f:facet name="header">
							<h:outputLabel value="#{message['rsltd.datatable']}" />
						</f:facet>
						
						<p:column headerText="#{message['consulta.contrato.nombreCompleto']}" sortBy="#{c.tbCliente.nombresCompletos}" >
		                    <h:outputText value="#{c.tbCliente.nombresCompletos}" />
		                </p:column>
		                
		                <p:column headerText="#{message['consulta.contrato.fecEntrega']}" sortBy="#{c.fechaCreacionString}"  >
		                    <h:outputText value="#{c.fechaEntregaString}" />
		                </p:column>
		                
		                <p:column headerText="#{message['consulta.contrato.numDoc']}" sortBy="#{c.tbCliente.numdocumento}" >
		                    <h:outputText value="#{c.tbCliente.numdocumento}" />
		                </p:column>
		                
		                <p:column headerText="#{message['consulta.contrato.estado']}" sortBy="#{c.tbEstadoGeneralEntrega.descripcion}" >
		                    <h:outputText value="#{c.tbEstadoGeneralEntrega.descripcion}" />
		                </p:column>
		                
		                <p:column headerText="#{message['consulta.cargar']}" >
			                <p:commandButton icon="ui-icon-close" title="cargar"  action="#{contratoForm.cargar}" update="@form" >
			                <f:setPropertyActionListener value="#{c.tbCliente.idcliente}" target="#{contratoForm.idcliente}" />
								<f:setPropertyActionListener value="#{c.idcontrato}" target="#{contratoForm.idcontrato}" />
							</p:commandButton>
						</p:column>
					</p:dataTable>
					</h:panelGrid>
			</p:panel>
			<div align="center"  style="margin-top:30px" >
		     	<h:graphicImage value="/images/Reporting_pdf.png" style="width:40px;height:40px"/>
				<p:commandLink action="#{contratoForm.ReportingPagos}" value="#{message['reporte.exportar.pagos.pdf']}" ajax="false" >
				<f:setPropertyActionListener target="#{contratoForm.contentType}" value="pdf"/>
				</p:commandLink>
				
				<h:graphicImage value="/images/excel_icon.PNG" style="width:40px;height:40px"/>
				<p:commandLink action="#{contratoForm.ReportingPagos}" value="#{message['reporte.exportar.pagos.xls']}" ajax="false" >
				<f:setPropertyActionListener target="#{contratoForm.contentType}" value="xls"/>
				</p:commandLink>
			</div>
		</h:form>
	</ui:define>
</ui:composition>